//
//  MDNavigationBarView.m
//  jewelryMD
//
//  Created by pro on 2018/8/30.
//  Copyright © 2018年 洪闽程. All rights reserved.
//
#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#import "MDNavigationBarView.h"

@implementation MDNavigationBarView

+ (MDNavigationBarView *)loadNavigationBarView {
    MDNavigationBarView *barView = [[[NSBundle mainBundle]loadNibNamed:@"MDNavigationBarView" owner:nil options:nil] objectAtIndex:0];
    if (kDevice_Is_iPhoneX) {
        barView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44);
    } else {
        barView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44);
    }
    return barView;
}

- (void)setIsAlpa:(BOOL)isAlpa {
    if (isAlpa == YES) {
        self.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:0.1];
        self.tintColor = [UIColor whiteColor];
        self.returnKeyType = 0;
        self.lineView.hidden = YES;
    } else {
        self.backgroundColor = [UIColor colorWithRed:50 green:50 blue:50 alpha:1];
        self.tintColor = [UIColor blackColor];
        self.returnKeyType = 1;
        self.lineView.hidden = NO;
    }
}

#pragma mark - color
- (void)setTintColor:(UIColor *)tintColor {
    self.titleLab.textColor = tintColor;
    [self.leftBtn setTitleColor:tintColor forState:UIControlStateNormal];
    [self.rightBtn setTitleColor:tintColor forState:UIControlStateNormal];
    [self.rightTwoBtn setTitleColor:tintColor forState:UIControlStateNormal];
}

- (void)setTitleColor:(UIColor *)titleColor {
    self.titleLab.textColor = titleColor;
}

- (void)setLeftBtnColor:(UIColor *)leftBtnColor {
    [self.leftBtn setTitleColor:leftBtnColor forState:UIControlStateNormal];
}

- (void)setRightBtnColor:(UIColor *)rightBtnColor {
    [self.rightBtn setTitleColor:rightBtnColor forState:UIControlStateNormal];
}

- (void)setRightTwoBtnColor:(UIColor *)rightTwoBtnColor {
    [self.rightTwoBtn setTitleColor:rightTwoBtnColor forState:UIControlStateNormal];
}

#pragma mark - 文字设置
- (void)setTitle:(NSString *)title {
    self.titleLab.text = title;
}

-(void)setRightBtnImage:(UIImage *)rightBtnImage
{
    [self.rightBtn setImage:rightBtnImage forState:UIControlStateNormal];
}

- (void)setLeftBtnTitle:(NSString *)leftBtnTitle {
    [self.leftBtn setTitle:leftBtnTitle forState:UIControlStateNormal];
}

- (void)setRightBtnTitle:(NSString *)rightBtnTitle {
    [self.rightBtn setTitle:rightBtnTitle forState:UIControlStateNormal];
}

- (void)setRightTwoBtnTitle:(NSString *)rightTwoBtnTitle
{
    [self.rightTwoBtn setTitle:rightTwoBtnTitle forState:UIControlStateNormal];
}

- (void)setReturnKeyType:(BACKKEYTYPE)returnKeyType {
    if (returnKeyType == 0) {//白色
        [self.leftBtn setImage:[UIImage imageNamed:@"seckill_icon_back"] forState:UIControlStateNormal];
    } else {//黑
        [self.leftBtn setImage:[UIImage imageNamed:@"navigation_back_normal"] forState:UIControlStateNormal];
    }
}



//默认左边按钮为返回操作
- (IBAction)backAction:(id)sender {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"popNotification" object:nil userInfo:nil];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
